package com.zyz.E_面向对象.O_代码块.静态代码块;

/**
 * @author: vick
 * @Date: 2025/3/18
 * @Description:
 * @version: 1.0
 */
public class Demo3 {
    String name;
    int age;

    static String desc = "vick";

    public Demo3() {
        System.out.println("无参构造器");
    }

    public Demo3(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("有参构造器");
    }

    static {
        System.out.println("静态代码块1");
        System.out.println(desc);
        desc = "1111";
        System.out.println(desc);
        info();
    }

    static {
        System.out.println("静态代码块2");
    }

    {
        System.out.println("非静态代码块1");
    }


    {
        System.out.println("非静态代码块2");
        age = 1;
        System.out.println(age);
        eat();
        desc = "2222";
        System.out.println(desc);
        info();
    }

    public void eat() {
        System.out.println("eat");
    }

    public static void info() {
        System.out.println("info");
    }
}
